home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / asm_subr.arc / MBINSUB < prev    next >
Encoding:
Text File  |  1985-12-28  |  1.8 KB  |  64 lines

  1. ;-------------------------mbinsub routine begins--------------------------+
  2. ; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
  3. ;         page : 118
  4. ;
  5. ; NAME  MBINSUB
  6. ;
  7. ; ROUTINE FOR Multidigit Binary Subtraction
  8. ;
  9. ; FUNCTION: This routine subtracts two multidigit binary numbers.
  10. ;
  11. ; INPUT: Upon entry DS:SI points to the first number; DS:DI points to
  12. ; the second number, and DS:BX points to the location where the result
  13. ; will be stored.  The size of these multidigit numbers is controlled
  14. ; by the constant ISIZE.  All three numbers contain 16*ISIZE number of
  15. ; bits and are stored in ISIZE number of 16-bit words of memory.
  16. ;
  17. ; OUTPUT: Upon exit DS:BX points to where the result is stored.
  18. ;
  19. ; REGISTERS USED:  No registers are modified.
  20. ;
  21. ; SEGMENTS REFERENCED:  Upon entry the data segment must contain
  22. ; storage for three multidigit numbers; two for input and one for output.
  23. ;
  24. ; ROUTINES CALLED:  None
  25. ;
  26. ; SPECIAL NOTES: None
  27. ;
  28. ; ROUTINE TO SUBTRACT MULTIDIGIT BINARY NUMBERS
  29. ;
  30. mbinsub    proc    far
  31. ;
  32.     push    si        ; save registers
  33.     push    di
  34.     push    bx
  35.     push    cx
  36.     push    ax
  37. ;
  38.     mov    cx,isize    ; get the number of 16-bit 'digits'
  39.     clc            ; clear the carry in
  40. ;
  41. mbinsub1:
  42.     mov    ax,[si]        ; get 'digit'' from 1st number
  43.     inc    si        ; point to next number
  44.     inc    si
  45.     sbb    ax,[di]        ; sub 'digit' from 2nd number
  46.     inc    di        ; point to next 'digit'
  47.     inc    di
  48.     mov    [bx],ax        ; move resulting digit into place
  49.     inc    bx        ; point to next free 'digit' place
  50.     inc    bx
  51.     loop    mbinsub1    ; loop through all the 'digits'
  52. ;
  53.     pop    ax        ; restore registers
  54.     pop    cx
  55.     pop    bx
  56.     pop    di
  57.     pop    si
  58.     ret
  59. ;
  60.     ret            ; return
  61. ;
  62. mbinsub    endp
  63. ;-------------------------mbinsub routine ends---------------------------+
  64.